<template>
  <div class="account-health" v-if="infoData.store">
    <Header :showNav="true" :storeName="infoData.store" :website="infoData.website" />
    <div class="account-container">
      <!-- 提示框 -->
      <!-- <div class="flex account-tips">
        <i class="notice-icon"></i>
        <p>Starting no earlier than December 1, 2022, you will need a mobile number to sign in to Seller Central. If you have already enrolled in two-step verification, you may ignore this message. <span>Learn more.</span></p>
      </div> -->
      <!-- 头部信息 -->
      <div class="flex title">
        <h3>Account Health</h3>
        <span>Leave Feedback</span>
      </div>
      <div class="flex flex-between account-info" style="align-items:flex-start">
        <div class="info-left">
          <p>To sell on Amazon, you must adhere to the below performance targets and policies.</p>
          <p>Help us reach you in the instance a critical event occurs that affects your ability to sell by entering your</p>
          <p>emergency contact number <span>here</span>.</p>
          <p class="pt-20"><span>Report abuse</span> of Amazon policies.</p>
        </div>
        <div class="info-right">
          <div class="guardian">
            <svg-icon icon-class="guardian" style="width:36px;height:48px;flex:none" />
            <div class="cont">
              <div class="tit">Account Health Assurance</div>
              <p>A new benefit for selling partners who consistently achieve a high Account Health Rating.</p>
              <div class="see">
                <span>See what it takes to qualify</span>
                <svg-icon icon-class="arrow" style="width:22px;height:22px;flex:none"/>
              </div>
            </div>
          </div>
          <div class="help">
            <p class="need-help">Need help?</p>
            <p class="notice">Speak to an Account Health Specialist.</p>
            <div class="flex">
              <div class="flex call-btn">
                <svg-icon icon-class="phoneIcon" />
                <p>Call me now</p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 卡片内容 -->
      <div class="card-list">
        <div class="card-box customer-service">
          <div class="card-top">
            <h3>Customer Service Performance</h3>
          </div>
          <div class="card-content">
            <div class="flex card-table-head">
              <span style="margin-right: 6.3%">Seller Fulfilled</span>
              <span>Fulfilled by Amazon</span>
            </div>
            <ul class="table-item-list" style="min-height: 366px; margin-bottom: 4px;">
              <li class="border" style="padding: 7px; margin-bottom: 0;">
                <div class="table-item" style="height: auto; padding-bottom: 0; border-bottom: 0;align-items: baseline;">
                  <div class="item-name" style="font-size: 16px;">Order Defect Rate</div>
                  <span>{{infoData.Order_Defect_Rate_Seller_Fulfilled}}</span>
                  <span v-if="infoData.Order_Defect_Rate_Fulfilled_by_Amazon!='N/A'">
                    <div style="font-size:24px;line-height:32px;color:#0F1111;">{{infoData.Order_Defect_Rate_Fulfilled_by_Amazon[1]}}</div>
                    <div style="font-size:12px;line-height:16px">{{infoData.Order_Defect_Rate_Fulfilled_by_Amazon[2]}}</div>
                    <div style="font-size:12px;line-height:16px">{{infoData.Order_Defect_Rate_Fulfilled_by_Amazon[3]}}</div>
                  </span>
                  <span v-else>{{infoData.Order_Defect_Rate_Seller_Fulfilled}}</span>
                </div>
                <p class="flex target" style="position:relative;" :style="{top: infoData.Order_Defect_Rate_Fulfilled_by_Amazon!='N/A'?'-36px':0}"><label>Target: </label>under 1%</p>
              </li>
              <li>
                <p class="item-tip" style="padding-left: 14px;">Order Defect Rate consists of three different metrics:</p>
                <div class="flex" style="padding-left: 14px;">
                  <span class="dot"></span>
                  <div class="table-item" style="padding-right: 7px;">
                    <div class="item-name">Negative feedback</div>
                    <span>{{infoData.Negative_feedback_Seller_Fulfilled}}</span>
                    <span>{{infoData.Negative_feedback_Fulfilled_by_Amazon}}</span>
                  </div>
                </div>
              </li>
              <li>
                <div class="flex" style="padding-left: 14px;">
                  <span class="dot"></span>
                  <div class="table-item" style="padding-right: 7px;">
                    <div class="item-name">A-to-z Guarantee claims</div>
                    <span>{{infoData['A-to-z_Guarantee_claims_Seller_Fulfilled']}}</span>
                    <span>{{infoData['A-to-z_Guarantee_claims_Fulfilled_by_Amazon']}}</span>
                  </div>
                </div>
              </li>
              <li>
                <div class="flex" style="padding-left: 14px;">
                  <span class="dot"></span>
                  <div class="table-item" style="padding-right: 7px;">
                    <div class="item-name">Chargeback claims</div>
                    <span>{{infoData['Chargeback_claims_Seller_Fulfilled']}}</span>
                    <span>{{infoData['Chargeback_claims_Fulfilled_by_Amazon']}}</span>
                  </div>
                </div>
              </li>
            </ul>
            <!-- <ul class="table-item-list">
              <li class="border" style="padding: 7px; margin-bottom: 0;">
                <div class="table-item" style="height: 24px; padding-bottom: 0; border-bottom: 0;">
                  <div class="item-name">Invoice Defect Rate</div>
                  <span>N/A</span>
                </div>
                <p class="flex target"><label>Target: </label>under 5%</p>
              </li>
            </ul> -->

            <div class="view-btn"><p>View details</p></div>
          </div>
        </div>
        <div class="card-box policy-compliance">
          <div class="card-top">
            <h3>Policy Compliance</h3>
            <div class="card-status">Healthy</div>
            <!-- <p class="flex target"><label>Target: </label>under 5%</p> -->
          </div>
          <div class="health-rating">
            <div class="health-rating-info">
              <div class="tit">Account Health Rating</div>
              <div class="des">This rating reflects your adherence to Amazon’s selling policies. <span>Learn more.</span></div>
            </div>
            <div class="health-rating-count">
              <div class="num">{{infoData.Account_Health_Rating}}</div>
              <ul>
                <li>
                  <span class="count">0</span>
                  <div class="fill" :style="{width: calcFill().line1+'%'}"></div>
                </li>
                <li>
                  <span class="count">100</span>
                  <div class="fill" :style="{width: calcFill().line2+'%'}"></div>
                </li>
                <li>
                  <span class="count">200</span>
                  <div class="fill" :style="{width: calcFill().line3+'%'}"></div>
                  <span class="count" style="float: right;">1000</span>
                </li>
              </ul>
            </div>
          </div>
          <div class="card-content">
            <ul class="policy-list">
              <li>
                <div class="item-name">Suspected Intellectual Property Violations</div>
                <p>{{infoData['Suspected_Intellectual_Property_Violations']}}</p>
              </li>
              <li>
                <div class="item-name">Received Intellectual Property Complaints</div>
                <p>{{infoData['Received_Intellectual_Property_Complaints']}}</p>
              </li>
              <li>
                <div class="item-name">Product Authenticity Complaints</div>
                <p>{{infoData['Product_Authenticity_Complaints']}}</p>
              </li>
              <li>
                <div class="item-name">Product Condition Customer Complaints</div>
                <p>{{infoData['Product_Condition_Customer_Complaints']}}</p>
              </li>
              <li>
                <div class="item-name">Food and Product Safety Issues</div>
                <p>{{infoData['Food_and_Product_Safety_lssues']}}</p>
              </li>
              <li>
                <div class="item-name">Listing Policy Violations</div>
                <p>{{infoData['Listing_Policy_Violations']}}</p>
              </li>
              <li>
                <div class="item-name">Restricted Product Policy Violations</div>
                <p>{{infoData['Restricted_Product_Policy_Violations']}}</p>
              </li>
              <li>
                <div class="item-name">Customer Product Reviews Policy Violations</div>
                <p>{{infoData['Customer_Product_Reviews_Policy_Violations']}}</p>
              </li>
              <li style="border-bottom: 0;">
                <div class="item-name">Other Policy Violations</div>
                <p>{{infoData['Other_Policy_Violations']}}</p>
              </li>
            </ul>
            <div class="view-btn"><p>View all (0)</p></div>
            <div class="flex flex-between policy-warning">
              <div class="item-name">Other Policy Violations</div>
              <p>{{infoData['']}}</p>
            </div>
          </div>
        </div>
        <div class="card-box performance">
          <div class="card-top">
            <h3>Shipping Performance</h3>
          </div>
          <div class="card-content">
            <div class="flex card-select">
              <p>Seller Fulfilled</p>
              <i>∨</i>
            </div>
            <ul class="table-item-list">
              <li class="border">
                <div class="table-item">
                  <div class="item-name">Late Dispatch Rate</div>
                  <span>N/A</span>
                </div>
                <p class="flex target"><label>Target: </label>under 4%</p>
              </li>
              <li class="border">
                <div class="table-item">
                  <div class="item-name">Pre-Fulfilment cancellation rate</div>
                  <span>N/A</span>
                </div>
                <p class="flex target"><label>Target: </label>under 2.5%</p>
              </li>
              <li class="border">
                <div class="table-item">
                  <div class="item-name">Valid Tracking Rate</div>
                  <span>N/A</span>
                </div>
                <p class="flex target"><label>Target: </label>under 95%</p>
              </li>
            </ul>
            <div style="height:100px"></div>
            <!-- <div class="view-here">View delivery eligibilities here</div> -->
            <div class="view-btn"><p>View details</p></div>
          </div>
        </div>
      </div>
      <div class="card-list other-list">
        <div class="card-box news">
          <div class="card-top">
            <h3>Account Health News</h3>
          </div>
          <div class="card-content">
            <div class="table-item">
              <div class="item-name">Amazon seller app is now available in Belgium!</div>
              <p>8 February 2023</p>
            </div>
            <div class="table-item">
              <div class="item-name">Monitor your account health with new Account Health page features</div>
              <p>19 January 2023</p>
            </div>
            <div class="view-btn"><p>More news</p></div>
          </div>
        </div>
        <div class="card-box compliance">
          <div class="card-top">
            <h3>Manage your compliance</h3>
          </div>
          <div class="card-content">
            <div class="table-item">
              <div class="item-name">Product Compliance Requests</div>
              <p>0</p>
            </div>
            <div class="view-btn"><p>View all (0)</p></div>
          </div>
        </div>
      </div>
    </div>
    <Footer></Footer>
    <Feedback></Feedback>
  </div>
</template>

<script>
import Header from '@/components/Header.vue'
import Footer from '@/components/Footer.vue'
import Feedback from '@/components/Feedback.vue'
import { get_amazon_datas } from '@/api/index.js'
export default {
  components: { Header, Footer, Feedback },
  data () {
    return {
      infoData: {}
    }
  },
  mounted () {
    this.get_amazon_datas()
  },
  methods: {
    get_amazon_datas () {
      get_amazon_datas().then(res => {
        // res.account_health.Order_Defect_Rate_Fulfilled_by_Amazon = 'N/A'
        this.infoData = res.account_health
        if (this.infoData.Order_Defect_Rate_Fulfilled_by_Amazon != 'N/A') {
          this.infoData.Order_Defect_Rate_Fulfilled_by_Amazon = res.account_health.Order_Defect_Rate_Fulfilled_by_Amazon.split('\n')
        }
      })
    },
    calcFill () {
      const num = this.infoData.Account_Health_Rating
      if (num <= 100) {
        return {
          line1: num,
          line2: 0,
          line3: 0
        }
      } else if (num <= 200) {
        return {
          line1: 100,
          line2: num - 100,
          line3: 0
        }
      } else {
        return {
          line1: 100,
          line2: 100,
          line3: (num - 200) / 800 * 100
        }
      }
    }
  }
}
</script>

<style lang="less" scoped>
.account-container {
  padding: 0 18px 14px;

  .account-tips {
    padding: 14px 18px 18px;
    border: 2px solid #1196AB;
    border-left-width: 12px;
    border-radius: 8px;

    .notice-icon {
      width: 18px;
      height: 18px;
      margin-right: 6px;
      background: url(../../assets/images/amz_star.png) no-repeat -258px -354px;
    }
    span {
      color: #007185;
    }
  }

  .title {
    padding: 4px 0;
    margin-top: 10px;
    h3 {
      font-size: 28px;
      line-height: 1;
    }
    span {
      padding-left: 14px;
      align-self: flex-end;
      line-height: 20px;
      color: #007185;
    }
  }

  .account-info {
    margin-bottom: 18px;
    p {
      line-height: 20px;
    }
    span {
      color: #007185;
    }
  }

  .info-right {
    width: 48%;
    display: flex;
    justify-content: flex-end;
    .guardian{
      width: 48%;
      background-color: #E2F4F7;
      display: flex;
      position: relative;
      border: 2px solid #008296;
      border-radius: 6px;
      padding: 15px;
      margin-right: 4%;
      .cont{
        flex: 1;
        margin-left: 15px;
        .tit{
          font-weight: 700;
          font-size: 18px;
          line-height: 24px;
          color: #004954;
        }
        p{
          padding: 0;
          margin: 0 0 14px 0;
          font-size: 14px;
          color: #004954;
        }
        .see{
          font-size: 14px;
          font-weight: bold;
          display: flex;
          align-items: center;
          span{
            color: #004954;
          }
        }
      }
    }
    .help{
      padding: 14px 18px;
      border-radius: 8px;
      background-color: #F0F2F2;
      border: 1px solid #F0F2F2;
      width: 30%;
      box-sizing: border-box;
      .need-help {
        font-size: 18px;
        font-weight: 600;
        line-height: 24px;
      }
      .notice {
        margin: 4px 0 19px;
        line-height: 20px;
      }
      .call-btn {
        height: 29px;
        padding: 0 10px;
        background-color: #FFD814;
        border: 1px solid #FFD814;
        border-radius: 7px;
        box-shadow: 0 2px 5px 0 rgba(213, 217, 217, .5);
        cursor: pointer;
        .svg-icon {
          width: 20px;
          height: 20px;
        }
      }
    }
  }

  .card-list {
    display: flex;

    .card-box {
      box-sizing: border-box;
      width: 31.948%;
      margin-right: 2%;
      align-self: baseline;
      border: 1px solid #D5D9D9;
      border-radius: 8px;
      &:nth-of-type(3n) {
        margin-right: 0;
      }
    }
    .card-top {
      padding: 14px 20px;
      border-bottom: 1px solid #D5D9D9;
      display: flex;
      justify-content: space-between;
      h3 {
        font-size: 18px;
        font-weight: 600;
        line-height: 24px;
      }
      .card-status{
        color: #FFF;
        background-color: #538000;
        padding: 5px 10px;
        border-radius: 20px;
        font-size: 14px;
        // line-height: 20px;
      }
    }
    .health-rating{
      background-color: #FAFAFA;
      border: 1px #D5D9D9 solid;
      border-left: none;
      border-right: 0;
      padding: 20px 20px 20px 21px;;
      display: flex;
      justify-content: space-between;
      .health-rating-info{
        width: 55%;
        .tit{
          font-weight: 700;
          font-size: 18px;
          line-height: 24px;
          padding-bottom: 4px;
        }
        .des{
          color: #0F1111;
          font-size: 14px;
          line-height: 20px;
          span{
            color: #007185;
          }
        }
      }
      .health-rating-count{
        width: 38%;
        .num{
          font-weight: 700;
          font-size: 18px;
          line-height: 24px;
          padding-bottom: 4px;
        }
        ul{
          display: flex;
          justify-content: space-between;
          border-radius: 100px;
          height: 10px;
          li{
            position: relative;
            background-color: #D5DBDB;
            &:nth-child(1){
              width: 19%;
              border-radius: 100px;
              border-radius: 6px 0 0 6px;
              .fill{
                border-radius: 6px 0 0 6px;
              }
            }
            &:nth-child(2){
              width: 29%;
            }
            &:nth-child(3){
              width: 48%;
              border-radius: 0 6px 6px 0;
              .fill{
                border-radius: 0 6px 6px 0;
              }
            }
            .fill{
              background-color: #538000;
              position: absolute;
              left: 0;
              top: 0;
              right: 0;
              bottom: 0;
            }
            .count{
              top: 9px;
              position: relative;
              font-size: 14px;
              line-height: 22px;
              color: #0F1111;
            }
          }
        }
      }
    }
    .card-content {
      padding: 10px 14px 0;
      .card-table-head {
        padding: 7px;
        justify-content: right;
        span {
          width: 29.11287%;
          white-space: nowrap;
          color: #565959;
          line-height: 20px;
          text-align: right;
        }
      }

      .table-item {
        flex: 1;
        height: 20px;
        display: flex;
        align-items: center;
        .item-name {
          margin-right: 6.3%;
          flex: 1;
          color: #007185;
          cursor: pointer;
        }
        span {
          box-sizing: border-box;
          width: 20.25453%;
          padding: 4px 6px;
          margin-right: 6.3%;
          color: #565959;
          text-align: right;
          &:last-of-type {
            width: 29.11287%;
            margin-right: 0;
          }
        }
      }
    }

    .table-item-list {
      li {
        box-sizing: border-box;
        padding: 7px;
        .target {
          height: 20px;
          font-size: 12px;
          color: #565959;
          label {
            margin-right: 2px;
            font-weight: 600;
          }
        }
      }
      .border {
        border: 1px solid #ddd;
        border-radius: 4px;
      }
    }

    .customer-service {
      li {
        padding: 0;
        margin-bottom: 24px;
      }
      .table-item-list {
        .item-tip {
          margin: 16px 0 12px;
          line-height: 20px;
        }
        .table-item {
          height: 28px;
          padding-bottom: 16px;
          border-bottom: 1px solid #ddd;
        }
        .dot {
          width: 4px;
          height: 4px;
          margin: 0 7px 17px;
          border-radius: 3px;
          background-color: #0F1111;
        }
      }
      .view-btn {
        margin-top: 22px;
      }
    }

    .policy-compliance {
      .item-name {
        align-self: baseline;
        color: #007185;
        line-height: 20px;
        cursor: pointer;
      }
      .policy-list {
        li {
          padding: 7px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          border-bottom: 1px solid #ddd;
          p {
            font-size: 24px;
            line-height: 32px;
          }
        }
      }
      .policy-warning {
        padding: 17px 7px;
        border-top: 1px solid #ddd;
        p {
          font-size: 24px;
          line-height: 32px;
        }
      }
    }

    .performance {
      li {
        min-height: 75px;
        margin-bottom: 4px;
      }
      .card-select{
        color: #565959!important;
        font-size: 14px;
        text-align: right;
        display: flex;
        justify-content: flex-end;
        padding: 7px 0;
        i{
          font-size: 11px;
          margin-left: 6px;
          transform: scale(.8);
        }
      }
    }
    .view-btn {
      position: relative;
      height: 44px;
      z-index: 0;
      background: linear-gradient(to bottom,rgba(0,0,0,.14),rgba(0,0,0,.03) 3px,transparent);
      &::before {
        content: '';
        display: block;
        width: 100%;
        height: 44px;
        background: linear-gradient(to right,#fff,rgba(255,255,255,0),#fff);
        background-color: transparent;
        z-index: 1;
      }
      p {
        margin-top: -29px;
        color: #007185;
        text-align: center;
        cursor: pointer;
      }
    }
  }

  .other-list {
    padding: 16px 0;
    margin-bottom: 46px;
    justify-content: right;
    .card-box {
      &:last-of-type {
        margin-right: 0;
      }
    }

    .news {
      .table-item {
        margin-bottom: 5px;
      }
    }
    .compliance {
      .table-item {
        padding-left: 7px;
        margin-bottom: 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        p {
          font-size: 24px;
          line-height: 32px;
        }
      }
    }
  }
}
</style>
